<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'EntryList.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
  <script type="text/javascript">
  function showAdd(){
  	alert($("#categoryId").val());
  	window.location.href='showAdd?categoryId='+$("#categoryId").val();
  }
  
  </script>
  
  
  </head>
  
  <body>
  <div align="center">
  <form action="show" method="post" id="frm">
 	 文档分类：<select name="categoryId" id="categoryId">
 	 	<option value="-1"> 全部</option>
    	<c:forEach var="category" items="${categoryList}">
    	<option value="${category.id}" 
    	<c:if test="${categoryId eq category.id }">
    	selected="selected"</c:if>>${category.name}</option>
    	</c:forEach>
    </select>
    
	<input type="submit" value="查询">  
	<input type="button" value="新增电子文档" onclick="showAdd()"/>  
    </form>
    </div>
    <table border="1" width="600" align="center">
   
    
   <a href="AddEntry.jsp">添加</a>
    
    <tr>
    	<td>文档编号</td>
    	<td>文档名称</td>
    	<td>文档摘要</td>
    	<td>上传人</td>
    	<td>上传时间</td>
    	<td>操作</td>
    </tr>
    <c:forEach items="${entryList}" var="entry" varStatus="stat">
    <tr <c:if test="${stat.index%2==0}">bgcolor="yellow"</c:if>>
    	<td>${entry.id}</td>
    	<td>${entry.title }</td>
    	<td>${entry.summary}</td>
    	<td>${entry.uploaduser}</td>
    	<td><fmt:formatDate value='${entry.createdate}' pattern='yyyy-MM-dd' /></td>
    	<td>
		<a href="findById?id=${entry.id}">修改</a>
		<a href="delete?id=${entry.id}">删除</a>
		</td>
    </tr>
    </c:forEach>
    <tr><td align="center" colspan="6">${message}</td></tr>
    </table>
  </body>
</html>
